This invention relates to machine vision systems, particularly to image processing.
Machine vision systems acquire, process, and interpret an image to perform multitudes of tasks, including inspection. The image acquired is a discrete, two-dimensional function I (x, y), where the value of the function at each point (x, y) represents one of a plurality of possible shades of grey. Both the coordinates x and y and the shades of gray are quantized. Typically, an image is a rectangle having a width and a height. Each point (x, y) in an image I (x, y) is called a pixel, and is associated with a quantized grey value, also called a grey scale value, e.g., an integer I (x, y) that falls within the range 0xe2x89xa6I (x, y)xe2x89xa6255 for eight bit representations. The quantized gray value of each pixel is usually a function of the radiance (power per unit solid angle per unit projected area) of a corresponding point in the scene that the image represents.
Further, each image is acquired using an overall gain and offset associated therewith, where gain denotes the dynamic range of the digital values that are assigned to the video signal and offset is the lower limit of the digital values that are assigned to the video signal. When the gain and offset values of an image are optimal, the distribution of brightness values occurring in a scene extends over the entire spectrum available of 256 grey scales. The grey scale assigned to the brightest part of the scene is near the high end of the range, whereas the grey scale assigned to the darkest part of the scene is near the opposite end. By spreading the visual data in a scene over a wider range of grey scales, there is finer resolution in the resulting data. Subtle variations in image brightness are preserved because they are mapped to distinct digital grey values.
The overall gain and offset of an image are determined by many parameters. A list of the more important of such parameters includes: illumination intensity, scene reflectivity, lens aperture, sensor gain and offset (including possible automatic control circuitry), and the gain and offset of the image digitizer. These parameters are hard to control in practicexe2x80x94ambient light levels can change with time of day, bulbs age, cameras, and digitizers may become defective and be replaced, and the reflectivity of the objects being viewed can vary.
Typically, a single gain coefficient and a single offset coefficient for an image are calculated, the image adjusted, if necessary, and other machine vision tasks implemented by algorithms that are often immune or designed around gain and offset. For instance, the independence of the correlation value to overall gain and offset allows considerable freedom in making models. To make a model of a feature, one needs to know the relative grey values of the model pixels, but not the absolute values. A model can be made by recording an image of the desired feature under certain imaging conditions, and be used under substantially different conditions as long as the relative brightness of the feature remains roughly constant. Further, for simple geometric patterns, a model can often be made from a mathematical formula or a description in a CAD database, with almost no knowledge of the imaging conditions that will be in effect when the model is used.
However, the image representation and some image processing algorithms that are dependent on absolute brightness suffer from gain and offset issues. For instance, if gain is less than optimum for all or part of the image, the digital values will have a smaller distribution, and small variations in signal amplitude will be assigned the same digital value. This can cause important low-contrast information to be lost. If the gain is greater than the optimum, one or both ends of the range might be clipped.
Further, a single gain and offset value may allow clean processing of a portion of the image, but not the entire image. For example, if grey values were grouped at opposing ends of the brightness spectrum, a gain appropriate for the entire image will still result in loss of low-contrast information at the opposing ends of the spectrum.
The invention provides methods and apparatuses for normalizing the intensity of an image, where normalizing the intensity of an image, optimally, equalizes the grey values in an image that represent a single brightness. The normalization of the invention minimizes the effect of extraneous variations in image brightness and contrast, whether the extraneous brightness variations are linear or non-linear brightness changes. An extraneous variation in brightness changes is due to factors other than features of the scene to be images. A linear brightness change in intensity is one wherein the grey-level value of each pixel varies uniformly across the entire image, and a non-linear brightness change in intensity is a non-uniform change in intensity across an image, which means the grey-level values in one region may vary more than in other regions (i.e. the grey-level values of a object of one brightness varies from one region to another region).
The normalization of the invention makes the grey values much more equal than the various grey values that represented an object of a single brightness in the image before normalization, although it may not equalize all the grey values representing each brightness. Further, the normalization of the invention brings the desired range of grey values and the actual range of grey values much closer, even though it may not exactly equalize the range of grey values (i.e. contrast) between two images or an image and a user""s criteria.
Instead of having a gain or offset for the entire image, the normalization generates an individual gain, and optionally an individual offset, for different portions of the image. First, the image is divided into sub-images. Next, the gain and optionally the offset coefficients for each of the sub-images are calculated. A function is then fitted to the gain and optionally the offset coefficients, respectively, giving each pixel or sub-pixel position its own interpolated gain and optionally offset. Lastly, the image is normalized using the functions by multiplying the intensities in the image by the gain at that position and optionally adding the offset at that position.
In one embodiment, the gain and optionally the offset coefficients are calculated by comparing a single intensity image to blurred sub-images. More particularly, the image is filtered to provide blurred sub-images coextensive with the plurality of sub-images. The relevant portion of the histogram of the single intensity image and the relevant portion of the histogram of each blurred sub-image provide the gain of each of the sub-images, where preferably the relevant portion is the mean of each histogram.
In one embodiment, a model image or model information is used to calculate the gain and optionally the offset coefficients of each sub-image, also called initial sub-images. More particularly, the relevant information from the histogram of the model-sub-images is associated with the relevant information from the histogram of the initial sub-images, and the gain and optionally the offset coefficients are calculated using the two histograms as known in the art. The relative portion of the histogram can be the tails, the means and optionally the standard deviations, or the distribution, for example. Further, in one embodiment, the association is accomplished by aligning a model image with the initial image.
Among other advantages, the normalization technique can be used with any image, not just a checkerboard and can accommodate both linear and non-linear changes in brightness to minimize the unwanted effect of changes in intensity, local and/or global.